//Erstellt von Moritz Liepe
package main;

import org.eclipse.draw2d.Figure;
import org.eclipse.draw2d.XYLayout;
import org.eclipse.draw2d.geometry.Rectangle;
import org.eclipse.swt.graphics.Color;


public class Selector extends Figure{
	
	private final XYLayout xyL = new XYLayout();
	
	public Selector() {
		Color bg = new Color(null,255,255,255);
	    this.setLayoutManager(xyL);
	    this.setBackgroundColor(bg);
	    this.setOpaque(true);
	}
	
	public void addFigure(Figure f){
		if(f instanceof Module){
			int insertionPosX = (this.getBounds().width/2)-(((Module)f).getWidth()/2);
			int insertionPosY = 10;
			for(int i=0; i < this.getChildren().size(); i++){
				insertionPosY += ((Module)this.getChildren().get(i)).getHeight() + 10;
			}
			this.add(f, new Rectangle(insertionPosX, insertionPosY, ((Module)f).getWidth(), ((Module)f).getHeight()));
		}
	}
}
